const Koa = require("koa")
const bodyParser = require("koa-bodyparser")
const KoaRouter = require("@koa/router")
const userRouter = require("../router/user.router.js")
const loginRouter = require("../router/login.router.js")
const registerRouters = require("../router/index.js")

const app = new Koa()

// 通过bodyParser中间件让客户端的body参数加在ctx.request.body里面
app.use(bodyParser())

// 动态注册所有路由
registerRouters(app)
// app.use(userRouter.routes())
// app.use(userRouter.allowedMethods())
// app.use(loginRouter.routes())
// app.use(loginRouter.allowedMethods())

module.exports = app
